unit FlashPlay;

interface

uses
  Controls, XMLIntf, lsComponent, Classes, ExtCtrls, ShockwaveFlashObjects_TLB;

type
  TFlashPlay = class(TlsComponent)
  private
    FPlayer: TShockwaveFlash;
    FLeft: Integer;
    FTop: Integer;
    FWidth: Integer;
    FHeight: Integer;
    FFileName: string;
  protected
   procedure innerDoAction(AAction: String); override;
  public
    constructor Create(AParent: TWinControl;AlsConfig: IXMLNode);override;
    destructor  Destroy;override;
    procedure SetProperty(ANode: IXMLNode);override;
  end;

implementation

uses
  CommonUtils;

{ TFlashPlay }

constructor TFlashPlay.Create(AParent: TWinControl; AlsConfig: IXMLNode);
begin
  inherited;

  FPlayer := TShockwaveFlash.Create(nil);
  FPlayer.Parent := FParent;
  FPlayer.Visible := False;
end;

destructor TFlashPlay.Destroy;
begin

  inherited;
end;

procedure TFlashPlay.innerDoAction(AAction: String);
begin
  inherited;

  if AAction='show' then
  begin
    FPlayer.Left := FLeft;
    FPlayer.Top := FTop;
    FPlayer.Width := FWidth;
    FPlayer.Height := FHeight;
    FPlayer.Visible := True;
    FPlayer.Play;
    FPlayer.Playing := True;
  end
  else if AAction='hide' then
  begin
    FPlayer.Stop;
    FPlayer.Visible:=False;
  end;
end;

procedure TFlashPlay.SetProperty(ANode: IXMLNode);
begin
  inherited;

  FFileName := PathOfTrain+ GetChildNodeValue(ANode, 'filename');
  FLeft := ANode.ChildNodes.FindNode('left').NodeValue;
  FTop := ANode.ChildNodes.FindNode('top').NodeValue;
  FWidth := ANode.ChildNodes.FindNode('width').NodeValue;
  FHeight := ANode.ChildNodes.FindNode('height').NodeValue;
  FPlayer.Movie := FFileName;
end;

end.
